Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@tiptap/extension-bubble-menu
Advanced tools
@tiptap/extension-bubble-menu is an extension for the Tiptap editor that provides a contextual menu (bubble menu) that appears when you select text. This menu can be customized to include various formatting options and actions, making it a powerful tool for enhancing the user experience in rich text editing.
Basic Bubble Menu
This code sets up a basic bubble menu that appears when text is selected. The menu is linked to a DOM element with the class 'bubble-menu'.
import { BubbleMenu } from '@tiptap/extension-bubble-menu';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';
const editor = new Editor({
extensions: [
StarterKit,
BubbleMenu.configure({
element: document.querySelector('.bubble-menu'),
}),
],
});
Custom Bubble Menu
This code configures a custom bubble menu with additional Tippy.js options, such as setting the duration of the menu's appearance animation.
import { BubbleMenu } from '@tiptap/extension-bubble-menu';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';
const editor = new Editor({
extensions: [
StarterKit,
BubbleMenu.configure({
element: document.querySelector('.custom-bubble-menu'),
tippyOptions: {
duration: 100,
},
}),
],
});
Conditional Bubble Menu
This code sets up a bubble menu that only appears when there is a text selection (i.e., the selection is not empty).
import { BubbleMenu } from '@tiptap/extension-bubble-menu';
import { Editor } from '@tiptap/core';
import StarterKit from '@tiptap/starter-kit';
const editor = new Editor({
extensions: [
StarterKit,
BubbleMenu.configure({
element: document.querySelector('.conditional-bubble-menu'),
shouldShow: ({ state }) => {
return state.selection.empty === false;
},
}),
],
});
ProseMirror-menu is a menu system for the ProseMirror editor. It provides a way to create and manage menus that can be attached to the editor. Compared to @tiptap/extension-bubble-menu, ProseMirror-menu is more generic and requires more manual setup for contextual menus.
Slate-react is a set of React components for the Slate editor. It allows for the creation of custom toolbars and menus, including bubble menus. While it offers similar functionality, it is designed specifically for use with the Slate editor and requires React.
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
Documentation can be found on the Tiptap website.
Tiptap is open sourced software licensed under the MIT license.
FAQs
bubble-menu extension for tiptap
The npm package @tiptap/extension-bubble-menu receives a total of 806,110 weekly downloads. As such, @tiptap/extension-bubble-menu popularity was classified as popular.
We found that @tiptap/extension-bubble-menu demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.